﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.SqlClient;
using System.Data;
namespace DAO
{
     public class LoaiTruSoDA
    {
         public static LoaiTruSo GetByID(int maID)
         {
             LoaiTruSo loai = null;
             SqlConnection cn = DataProvider.Connect();
             SqlCommand cmd = new SqlCommand("Proc_LoaiTruSo_GetById", cn);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@maTruSo", maID));
             SqlDataReader dataReader = cmd.ExecuteReader();
             if (dataReader.Read())
             {
                 loai = new LoaiTruSo();
                 loai.MaLoaiTruSo = maID;
                 loai.Ten = Convert.ToString(dataReader["Ten"]);
                 loai.MoTa = Convert.ToString(dataReader["MoTa"]);
              }
             cn.Close();
             return loai;
         }

    }
}
